// preload.js
const { contextBridge, ipcRenderer } = require('electron')
const path = require('path');

document.addEventListener("drop", (e) => {
	//阻止默认行为
	e.preventDefault();
	//获取文件列表
	const files = e.dataTransfer.files;

	if (files && files.length > 0) {
		//获取文件路径
		const path = files[0].path;
		console.log('path:', path);

		ipcRenderer.send('ondragstart', path);
		//读取文件内容
		//const content = fs.readFileSync(path);
		//console.log(content.toString());
	}
})

document.addEventListener("dragover", (e) => {
	e.preventDefault();
});


// All of the Node.js APIs are available in the preload process.
// It has the same sandbox as a Chrome extension.
window.addEventListener('DOMContentLoaded', () => {

})
